import pygame
from pygame.sprite import Sprite


class Alien(Sprite):
    """单个外星人"""

    def __init__(self, ai_setting, screen):
        super(Alien, self).__init__()
        self.ai_setting = ai_setting;
        self.screen = screen;
        self.image = pygame.image.load("images/alien.bmp")
        #self.image = pygame.image.load(r"f:\python_work\images\alien.bmp")
        self.rect = self.image.get_rect();
        self.rect.x = self.rect.width;
        self.rect.y = self.rect.height;
        self.x = (float)(self.rect.x);
        self.y = (float)(self.rect.y);

    def drawAlien(self):
        self.screen.blit(self.image, self.rect);

    # 向左向右移动
    def update(self):
        self.x += (self.ai_setting.alien_speed_factor * self.ai_setting.feet_direction);
        self.rect.x = self.x;

    # 检查边缘
    def check_edge(self):
        screen_rect = self.screen.get_rect();
        if self.rect.right >= screen_rect.right:
            return True;
        elif self.rect.left <= 0:
            return True;
